package com.kapcb.common.event;

import lombok.Setter;
import lombok.ToString;

/**
 * <a>Title: Event </a>
 * <a>Author: cb <a>
 * <a>Description: Event <a>
 *
 * @author cb
 * @version 1.0
 * @date 2024/4/19 9:59 PM
 * @since 1.0
 */
@Setter
@ToString
public class Event<T> implements IEvent<T> {

    /**
     * 事件创建的系统时间戳
     */
    private Long timestamp;

    /**
     * 事件类型
     */
    private String eventType;

    /**
     * 消息体
     */
    private T payload;

    public Event() {
    }

    public Event(String eventType, T payload) {
        this.timestamp = System.currentTimeMillis();
        this.eventType = eventType;
        this.payload = payload;
    }

    public Event(Long timestamp, String eventType, T payload) {
        this.timestamp = timestamp;
        this.eventType = eventType;
        this.payload = payload;
    }

    @Override
    public Long timestamp() {
        return this.timestamp;
    }

    @Override
    public String eventType() {
        return this.eventType;
    }

    @Override
    public T payload() {
        return this.payload;
    }

}
